//
//  SolarSeekAddress.m
//  SolarSeek
//
//  Created by Erick Fejta on 05/06/16.
//  Copyright 2005 __MyCompanyName__. All rights reserved.
//

#import "SolarSeekAddress.h"
#import "Connections.h"
#import "NetSocket.h"

@implementation SolarSeekAddress
- (id)initWithAddress:(NSString *)a port:(UInt16)p {
	self = [super init];
	address = [a retain];
	port = p;
	return self;
}

- (id)initWithAddressFromInt:(unsigned int)fourbytes port:(UInt16)p {
	return [self initWithAddress:MakeNSStringFromInternetAddress(fourbytes) port:p];
}

- (void)dealloc {
	[address release];
	address = nil;
	[super dealloc];
}

- (NSString *)address { return address; }
- (UInt16)port { return port; }

- (NSString *)description { return [address stringByAppendingFormat:@":%d",port]; }

- (void)setAddress:(NSString *)a { 
	[self willChangeValueForKey:@"description"];
	[a retain]; [address release]; address = a; 
	[self didChangeValueForKey:@"description"];
}
- (void)setPort:(UInt16)p { 
	[self willChangeValueForKey:@"description"];
	port = p; 
	[self didChangeValueForKey:@"description"];
}
- (void)setAddressFromInt:(unsigned int)fourbytes { [self setAddress:MakeNSStringFromInternetAddress(fourbytes)]; }


@end
